package com.xuxu.blog.dao;

import com.xuxu.blog.entity.ArticleEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 
 * 
 * @author maxuxu
 * @email maxuxu019@gmail.com
 * @date 2022-08-21 22:22:32
 */
@Mapper
// @CacheNamespace(implementation= MybatisPlusRedisCache.class,eviction=MybatisPlusRedisCache.class)
public interface ArticleDao extends BaseMapper<ArticleEntity> {
    @Select("select count(DISTINCT id) count,category from article  where author=#{author} group by category")
    List<ArticleEntity> selectGroupByAuthor(String author);
    @Select("select count(DISTINCT id) count,category from article where flag = '1' group by category")
    List<ArticleEntity> selectGroup();
    @Select("select tag ,count(DISTINCT id) count,GROUP_CONCAT(id) ids from article where author=#{author} group by tag")
    List<ArticleEntity> getByTags(String author);
    // 获取文章个数
    Integer getCountInteger();


    // 获取前10篇文章 此处返回id,time,img,title
    List<ArticleEntity> selectNewByAuthor(String author);

    // 倒序分页查询数据
}
